package com.generics;

import java.util.Arrays;
import java.util.Objects;

public class MyArrayList<E,T> {
    private Object[]arr=new Object[10];
    private int size;

    public boolean add(E e){
        arr[size++]=e;
        return true;
    }

    @Override
    public boolean equals(Object o) {
        //1.判断两个对象的地址是否一样
        if (this == o) return true;
        //2.判断o是不是null或者是不hi是类型是否相同，采用getClass函数
        if (o == null || getClass() != o.getClass()) return false;
        //3.开始比较内容

        MyArrayList<?, ?> that = (MyArrayList<?, ?>) o;
        return size == that.size && Arrays.equals(arr, that.arr);
    }

    @Override
    public int hashCode() {
        int result = Objects.hash(size);
        result = 31 * result + Arrays.hashCode(arr);
        return result;
    }

    public E get(int index){

        return (E) arr[index];
    }
}
